home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / libs / knowhow4 / kit.h < prev    next >
C/C++ Source or Header  |  1994-10-10  |  2KB  |  57 lines

  1. //  KIT.H  common part of object and application containers.
  2.  
  3. #ifndef __KIT_H_
  4. #define __KIT_H_
  5.  
  6. #include "visible.h"
  7. #include <alloc.h>
  8. #include <string.h>
  9.  
  10. #define DELTA 20
  11.     // step in reallocation of the memory for list
  12.  
  13. class Kit
  14.     {
  15.     protected:
  16.     Visible** list;     // objects in the Kit
  17.     int current;        // number of the current object
  18.     int used;           // total number of objects in container
  19.     int size;           // allocated >= used
  20.     char* help_context; // help context of container
  21.  
  22.     public:
  23.     Kit();
  24.  
  25.     virtual ~Kit();
  26.  
  27.     void set_help_context(char* hName);
  28.     int pos() { return current; }
  29.     int add(Visible* object);  // add object to the end of the list
  30.  
  31.     Visible* get(int number) { return list[number]; }
  32.     int get(Visible*);       // return No in the container. ATTENTION!
  33.                  // returns FIRST occurrence of pointer!
  34.  
  35.     int moveTo(int number)
  36.         {
  37.         if(number <= used)
  38.         current = number;
  39.         return current;
  40.         }
  41.  
  42.     int shift()  // go to the next object
  43.         {
  44.         current = (current < used) ? current + 1 : 1;
  45.               return current;
  46.         }
  47.     Visible* remove(int number);    // remove from list but doesn't delete
  48.     void insert(Visible* object, int number); // add to the current position
  49.                      // and shift objects with largest numbers
  50.     void background(Visible* back_object) { list[0] = back_object; }
  51.          // this is "supply" object, of Window class, which is present in
  52.          // Kit, but is not listed during iterations
  53.     };
  54.  
  55.  
  56. #endif __KIT_H_
  57.